<template>
  <div class="condition-layout">
    <component ref="conditionRef" :is="conditionComponents[props.data.type]" :data="props.data"/>
  </div>
</template>

<script setup>
import {defineAsyncComponent, getCurrentInstance, shallowRef} from "vue";
import {conditionTypes} from "@/components/EasyProcess/config/conditionType";

const { proxy } = getCurrentInstance();

const props = defineProps({
  data: {
    type: Object,
    default: {}
  }
});

const conditionComponents = shallowRef({});
const modules = import.meta.glob('./*Condition.vue')

conditionTypes.forEach(key => {
  // 加载节点组件
  conditionComponents.value[key] = defineAsyncComponent(modules[`./${key}Condition.vue`])
})
</script>

<style scoped lang="scss">
.condition-layout {
  width: 100%;
}
</style>